#!/bin/sh -e
# - scaling_max_freq
# - scaling_min_freq

[ -n "$scaling_max_freq" ] || [ -n "$scaling_min_freq" ] || exit 0

. $LKP_SRC/lib/reproduce-log.sh

[ ${scaling_max_freq%%%} != $scaling_max_freq ] && {
	cpuinfo_max_freq=$(cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq)
	scaling_max_freq=${scaling_max_freq%%%}
	scaling_max_freq=$(( cpuinfo_max_freq * scaling_max_freq / 100 ))
}

log_echo "
	for i in \$(seq 0 \$((\$(nproc)-1)))
	do
		[ -n "scaling_max_freq" ] && echo $scaling_max_freq > /sys/devices/system/cpu/cpu\$i/cpufreq/scaling_max_freq
		[ -n "scaling_min_freq" ] && echo $scaling_min_freq > /sys/devices/system/cpu/cpu\$i/cpufreq/scaling_min_freq
	done
"

for i in $(seq 0 $((nr_cpu-1)))
do
	[ -n "scaling_max_freq" ] && echo $scaling_max_freq > /sys/devices/system/cpu/cpu$i/cpufreq/scaling_max_freq
	[ -n "scaling_min_freq" ] && echo $scaling_min_freq > /sys/devices/system/cpu/cpu$i/cpufreq/scaling_min_freq
done
